#include "../logs/mylog.h"


void test_log(const std::string& name)
{INFO("测试开始");
 mylog::Logger::ptr logger=mylog::LoggerManager::getInstance().getLogger(name);
logger->debug("%s","测试日志");  
// logger->info("%s","测试日志");
// logger->warn("%s","测试日志");
// logger->fatal("%s","测试日志");
// logger->error("%s","测试日志");
// INFO("测试结束");
// mylog::Logger::ptr logger=mylog::LoggerManager::getInstance().getLogger("async_logger");
//   DEBUG("%s","测试日志");  
//  INFO("%s","测试日志");
//  WARN("%s","测试日志");
// FATAL("%s","测试日志");
//  ERROR("%s","测试日志");
//   size_t cursize=0;
//     while(cursize<10*1024*1024)
//     {
//        FATAL("测试日志-%d",cursize++);
       
//     }
}
int main()
{


std::unique_ptr<mylog::LoggerBuilder> builder(new mylog::GlobalLoggerBuilder());
builder->buildLoggerFormatter("[%c][%p]%m%n");
builder->buildLoggerType(mylog::LoggerType::LOGGER_SYNC);
builder->buildLoggerLevel(mylog::LogLevel::value::DEBUG);
builder->buildLoggerName("async_logger");
builder->buildSink<mylog::StdoutSink>();
builder->buildSink<mylog::FileSink>("./logfile/sync.log");
builder->buildSink<mylog::RollSink>("./logfile/roll-sync-by-size",1024*1024);
builder->build();
test_log("async_logger");



   




  

    // mylog::LogSink::ptr stdout_ptr=mylog::SinkFactory::create<mylog::StdoutSink>();
    // mylog::LogSink::ptr file_ptr=mylog::SinkFactory::create<mylog::FileSink>("./logfile/test.log");
    // mylog::LogSink::ptr roll_ptr=mylog::SinkFactory::create<mylog::RollSink>("./logfile/roll-",1024*1024);
    // stdout_ptr->log(s.c_str(),s.size());
    // file_ptr->log(s.c_str(),s.size());
    // size_t cursize=0;
    // while(cursize<10*1024*1024)
    // {
    //     roll_ptr->log(s.c_str(),s.size());
    //     cursize+=s.size();
    // }



   // std::cout<<mylog::util::date::now()<<std::endl;
   // std::string name="./a/b/c.txt";
   // mylog::util::file::create_directory(mylog::util::file::path(name));


   //    std::string logger_name ="sync_logger";
//    mylog::LogLevel::value limit =mylog::LogLevel::value::WARN;
//    mylog::LogSink::ptr stdout_ptr=mylog::SinkFactory::create<mylog::StdoutSink>();
//    mylog::LogSink::ptr file_ptr=mylog::SinkFactory::create<mylog::FileSink>("./logfile/test.log");
// std::vector< mylog::LogSink::ptr> sinks={stdout_ptr,file_ptr};
// mylog::Formatter::ptr fmt(new mylog::Formatter());
// mylog::Logger::ptr logger(new mylog::SyncLogger(logger_name,limit,fmt,sinks));
   return 0;
}
